package Cy.Servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import Cy.DAO.CommodityDAO;
import Entity.Brand;
import Entity.Color;
import Entity.CommodityType;
import Entity.Size;
import Factory.CommodityFactory;

/**
 * Servlet implementation class SelectAddCommodity
 */
@WebServlet("/selectaddcommodity")
public class SelectAddCommodity extends HttpServlet {
	private static final long serialVersionUID = 1L;
	private CommodityDAO commodity = CommodityFactory.createDAO();
	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		List<CommodityType> ctlist = commodity.selectctname();
		List<Brand> brandlist = commodity.selectbname();
		List<Color> colorlist = commodity.selectcolor();
		List<Size> sizelist = commodity.selectsize();
		/*String cname = request.getParameter("cname");
		int ctid = Integer.parseInt(request.getParameter("ctid"));
		int bid = Integer.parseInt(request.getParameter("bid"));*/
		String erorr = request.getParameter("erorr");
		request.setAttribute("ctlist", ctlist);
		request.setAttribute("brandlist", brandlist);
		request.setAttribute("colorlist", colorlist);
		request.setAttribute("sizelist", sizelist);
		/*request.setAttribute("ctid", ctid);
		request.setAttribute("bid", bid);
		request.setAttribute("cname", cname);*/
		request.setAttribute("erorr", erorr);
		request.getRequestDispatcher("addCommodity.jsp").forward(request, response);
	}
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		this.doGet(req, resp);
	}

}
